<script setup>
import { ref } from "vue";
import SectionTitle from "../common/SectionTitle.vue";

const news = ref([
  {
    id: 1,
    title: "公司成功研发新一代智能收割机",
    description:
      "我司最新研发的智能收割机，采用AI技术，大幅提高了收割效率和精度...",
    date: "2023-11-11",
    image: "news-image-1",
  },
  {
    id: 2,
    title: "远实智能亮相2023农业科技展",
    description:
      "我司携最新农机产品亮相2023全国农业科技展，吸引众多行业关注...",
    date: "2023-11-12",
    image: "news-image-2",
  },
  {
    id: 3,
    title: "公司与农业大学达成战略合作",
    description:
      "我司与国内知名农业大学签署战略合作协议，共同推进智慧农业发展...",
    date: "2023-11-13",
    image: "news-image-3",
  },
]);
</script>

<template>
  <section class="section news-section" id="news">
    <div class="section-container">
      <SectionTitle title="新闻资讯" />
      <el-row :gutter="20" class="news-list">
        <el-col :xs="24" :sm="12" :md="8" v-for="item in news" :key="item.id">
          <div class="news-card">
            <div :class="['news-image', item.image]"></div>
            <div class="news-info">
              <span class="news-date">{{ item.date }}</span>
              <h3>{{ item.title }}</h3>
              <p>{{ item.description }}</p>
              <a href="#" class="news-link">阅读更多</a>
            </div>
          </div>
        </el-col>
      </el-row>
      <div class="view-more">
        <el-button type="primary" plain>查看更多新闻</el-button>
      </div>
    </div>
  </section>
</template>

<style scoped>
.section {
  padding: var(--section-padding);
}

.section-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.news-list {
  margin-bottom: 30px;
}

.news-card {
  background-color: #fff;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
  height: 100%;
  transition: transform 0.3s ease;
}

.news-card:hover {
  transform: translateY(-5px);
}

.news-image {
  height: 200px;
  background-size: cover;
  background-position: center;
}

.news-image-1 {
  background-image: url("https://images.unsplash.com/photo-1625243338629-28c3f5b7ea55?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80");
}

.news-image-2 {
  background-image: url("https://images.unsplash.com/photo-1625246333195-78d9c38ad449?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80");
}

.news-image-3 {
  background-image: url("https://images.unsplash.com/photo-1625243338629-7c8e0ed9a93c?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80");
}

.news-info {
  padding: 20px;
}

.news-date {
  color: #999;
  font-size: 14px;
}

.news-info h3 {
  margin: 10px 0;
  font-size: 18px;
  line-height: 1.4;
}

.news-info p {
  margin-bottom: 15px;
  color: var(--text-color-light);
  font-size: 14px;
  line-height: 1.6;
}

.news-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: bold;
  font-size: 14px;
}

.news-link:hover {
  text-decoration: underline;
}

.view-more {
  text-align: center;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .section {
    padding: 60px 0;
  }

  .news-image {
    height: 180px;
  }
}

@media (max-width: 576px) {
  .section {
    padding: 40px 0;
  }

  .news-image {
    height: 160px;
  }

  .news-info h3 {
    font-size: 16px;
  }
}
</style> 